
#include "CNotifyMgr.h"
#include "CenterService.h"
#include "Common/TableDataEx/ChatCfg.h"
#include "Common/ChatDefine.h"
#include "Cache/OfflineCharacterDataMgr.h"
#include "ChatCenter/ChatCenter.h"

CNotifyMgr::CNotifyMgr()
{
}

CNotifyMgr::~CNotifyMgr()
{
}

bool CNotifyMgr::Init()
{	
	return true;
}

void CNotifyMgr::UnInit()
{

}

void CNotifyMgr::OnExecute(uint16_t nEventID, uint64_t nSrcID, uint8_t bySrcType, void *pContext, int32_t nLen)
{
	switch (nEventID)
	{
	case 0:
		{
		}
		break;
	}
}

//竞技场排名改变
void CNotifyMgr::OnArenaRankChange(CharIDType srcCid, int32_t rank)
{
	int32_t chatId = g_GetChatCfgMgr()->ChatIDByEventType(EChatSpecialEvent_ArenaRank, rank);
	if (chatId <= 0)
	{
		return;
	}
	OfflineCharacterData *pOffline = g_GetOfflineCharacterDataMgr()->GetOfflineCharacter(srcCid);
	if (nullptr == pOffline)
	{
		LogErrFmtPrint("CNotifyMgr::OnArenaRankChange..nullptr == pOffline..cid:%lu,rank:%d ", srcCid, rank);
		return;
	}
	SystemChatMsgData notify;
	notify.text.push_back(pOffline->GetCharName());
	g_GetChatCenter()->SendWorldBroadcastChat((BROADCAST_TYPE)chatId, notify);
}	

//工会大厅等级改变
void CNotifyMgr::OnUnionHallLev(string strUnionName, int32_t level)
{
	int32_t chatId = g_GetChatCfgMgr()->ChatIDByEventType(EChatSpecialEvent_UnionHall, level);
	if (chatId <= 0)
	{
		return;
	}
	SystemChatMsgData notify;
	notify.text.push_back(strUnionName);
	notify.params.push_back(level);
	g_GetChatCenter()->SendWorldBroadcastChat((BROADCAST_TYPE)chatId, notify);
}